//
//  UIBarButtonItem-Extension.swift
//  ZLWeibo
//
//  Created by zhanglongtao on 16/12/16.
//  Copyright © 2016年 hanju001. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    ///创建UIBarButtonItem
    convenience init(title: String, fontsize: CGFloat = 16,target: AnyObject?, action: Selector, isBackButton: Bool = false) {
        
        let btn: UIButton = UIButton.hm_textButton(title, fontSize: fontsize, normalColor: UIColor.darkGray, highlight: UIColor.orange)
        btn.addTarget(target, action: action, for: .touchUpInside)
        
        if isBackButton{
            
            let imageName = "navigationbar_back_withtext"
            let imageNameHight = "offical_live_allscreen_back_highlighted"
            btn.setImage(UIImage(named: imageName), for: UIControlState(rawValue: 0))
            btn.setImage(UIImage(named: imageNameHight), for: .highlighted)
        
        }
        btn.sizeToFit()
        self.init(customView: btn)
        
    }
}
